package lily.phs.object;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import lily.phs.database.Constants;

public class VaccinationCard implements Constants{
	private static final String[] PROJECTION = new String[] { 
		VACA_PROFILE_ID
	};
	private Context myContext;
	private int vaca_profile_id=-1;
	private String vaca_name=""; 
	private String vaca_sex=""; 
	private String vaca_born=""; 
	private String vaca_nation=""; 
	private String vaca_number_name=""; 
	private String vaca_child_id=""; 
	private String vaca_child_born_id=""; 
	private String vaca_guardian_name=""; 
	private String vaca_relation=""; 
	private String vaca_guardian_phone=""; 
	private String vaca_home_address=""; 
	private int vaca_census_address=-1; 
	private String vaca_census_address2=""; 
	private String vaca_immigration_time=""; 
	private String vaca_emigration_time=""; 
	private String vaca_emigration_reason=""; 
	private String vaca_vaccine_anomalies_his=""; 
	private String vaca_contraindication=""; 
	private String vaca_infect_his=""; 
	private String vaca_create_card_date=""; 
	private String vaca_create_card_people="";
	public VaccinationCard(Context context){
		this.myContext=context;
	}
	public int getVaca_profile_id() {
		return vaca_profile_id;
	}
	public void setVaca_profile_id(int vacaProfileId) {
		vaca_profile_id = vacaProfileId;
	}
	public String getVaca_name() {
		return vaca_name;
	}
	public void setVaca_name(String vacaName) {
		vaca_name = vacaName;
	}
	public String getVaca_sex() {
		return vaca_sex;
	}
	public void setVaca_sex(String vacaSex) {
		vaca_sex = vacaSex;
	}
	public String getVaca_born() {
		return vaca_born;
	}
	public void setVaca_born(String vacaBorn) {
		vaca_born = vacaBorn;
	}
	public String getVaca_nation() {
		return vaca_nation;
	}
	public void setVaca_nation(String vacaNation) {
		vaca_nation = vacaNation;
	}
	public String getVaca_number_name() {
		return vaca_number_name;
	}
	public void setVaca_number_name(String vacaNumberName) {
		vaca_number_name = vacaNumberName;
	}
	public String getVaca_child_id() {
		return vaca_child_id;
	}
	public void setVaca_child_id(String vacaChildId) {
		vaca_child_id = vacaChildId;
	}
	public String getVaca_child_born_id() {
		return vaca_child_born_id;
	}
	public void setVaca_child_born_id(String vacaChildBornId) {
		vaca_child_born_id = vacaChildBornId;
	}
	public String getVaca_guardian_name() {
		return vaca_guardian_name;
	}
	public void setVaca_guardian_name(String vacaGuardianName) {
		vaca_guardian_name = vacaGuardianName;
	}
	public String getVaca_relation() {
		return vaca_relation;
	}
	public void setVaca_relation(String vacaRelation) {
		vaca_relation = vacaRelation;
	}
	public String getVaca_guardian_phone() {
		return vaca_guardian_phone;
	}
	public void setVaca_guardian_phone(String vacaGuardianPhone) {
		vaca_guardian_phone = vacaGuardianPhone;
	}
	public String getVaca_home_address() {
		return vaca_home_address;
	}
	public void setVaca_home_address(String vacaHomeAddress) {
		vaca_home_address = vacaHomeAddress;
	}
	public int getVaca_census_address() {
		return vaca_census_address;
	}
	public void setVaca_census_address(int vacaCensusAddress) {
		vaca_census_address = vacaCensusAddress;
	}
	public String getVaca_census_address2() {
		return vaca_census_address2;
	}
	public void setVaca_census_address2(String vacaCensusAddress2) {
		vaca_census_address2 = vacaCensusAddress2;
	}
	public String getVaca_immigration_time() {
		return vaca_immigration_time;
	}
	public void setVaca_immigration_time(String vacaImmigrationTime) {
		vaca_immigration_time = vacaImmigrationTime;
	}
	public String getVaca_emigration_time() {
		return vaca_emigration_time;
	}
	public void setVaca_emigration_time(String vacaEmigrationTime) {
		vaca_emigration_time = vacaEmigrationTime;
	}
	public String getVaca_emigration_reason() {
		return vaca_emigration_reason;
	}
	public void setVaca_emigration_reason(String vacaEmigrationReason) {
		vaca_emigration_reason = vacaEmigrationReason;
	}
	public String getVaca_vaccine_anomalies_his() {
		return vaca_vaccine_anomalies_his;
	}
	public void setVaca_vaccine_anomalies_his(String vacaVaccineAnomaliesHis) {
		vaca_vaccine_anomalies_his = vacaVaccineAnomaliesHis;
	}
	public String getVaca_contraindication() {
		return vaca_contraindication;
	}
	public void setVaca_contraindication(String vacaContraindication) {
		vaca_contraindication = vacaContraindication;
	}
	public String getVaca_infect_his() {
		return vaca_infect_his;
	}
	public void setVaca_infect_his(String vacaInfectHis) {
		vaca_infect_his = vacaInfectHis;
	}
	public String getVaca_create_card_date() {
		return vaca_create_card_date;
	}
	public void setVaca_create_card_date(String vacaCreateCardDate) {
		vaca_create_card_date = vacaCreateCardDate;
	}
	public String getVaca_create_card_people() {
		return vaca_create_card_people;
	}
	public void setVaca_create_card_people(String vacaCreateCardPeople) {
		vaca_create_card_people = vacaCreateCardPeople;
	} 
	public void insertVaccinationCard(){
		ContentValues value= new ContentValues();
		value.put(VACA_PROFILE_ID, this.getVaca_profile_id());
		value.put(VACA_NAME, this.getVaca_name());
		value.put(VACA_SEX, this.getVaca_sex());
		value.put(VACA_BORN, this.getVaca_born());
		value.put(VACA_NATION, this.getVaca_nation());
		value.put(VACA_NUMBER_NAME, this.getVaca_number_name());
		value.put(VACA_CHILD_ID, this.getVaca_child_id());
		value.put(VACA_CHILD_BORN_ID, this.getVaca_child_born_id());
		value.put(VACA_GUARDIAN_NAME, this.getVaca_guardian_name());
		value.put(VACA_RELATION, this.getVaca_relation());
		value.put(VACA_GUARDIAN_PHONE, this.getVaca_guardian_phone());
		value.put(VACA_HOME_ADDRESS, this.getVaca_home_address());
		value.put(VACA_CENSUS_ADDRESS, this.getVaca_census_address());
		value.put(VACA_CENSUS_ADDRESS2, this.getVaca_census_address2());
		value.put(VACA_IMMIGRATION_TIME, this.getVaca_immigration_time());
		value.put(VACA_EMIGRATION_TIME, this.getVaca_emigration_time());
		value.put(VACA_EMIGRATION_REASON, this.getVaca_emigration_reason());
		value.put(VACA_VACCINE_ANOMALIES_HIS, this.getVaca_vaccine_anomalies_his());
		value.put(VACA_CONTRAINDICATION, this.getVaca_contraindication());
		value.put(VACA_INFECT_HIS, this.getVaca_infect_his());
		value.put(VACA_CREATE_CARD_DATE, this.getVaca_create_card_date());
		value.put(VACA_CREATE_CARD_PEOPLE, this.getVaca_create_card_people());	
		myContext.getContentResolver().insert(CONTENT_URI_TB21, value);
	}
	public void updateVaccinationCard(int pro){
		ContentValues value=new ContentValues();
		value.put(VACA_PROFILE_ID, this.vaca_profile_id);
		value.put(VACA_NAME, this.vaca_name);
		value.put(VACA_SEX, this.vaca_sex);
		value.put(VACA_BORN, this.vaca_born);
		value.put(VACA_NATION, this.vaca_nation);
		value.put(VACA_NUMBER_NAME, this.vaca_number_name);
		value.put(VACA_CHILD_ID, this.vaca_child_id);
		value.put(VACA_CHILD_BORN_ID, this.vaca_child_born_id);
		value.put(VACA_GUARDIAN_NAME, this.vaca_guardian_name);
		value.put(VACA_RELATION, this.vaca_relation);
		value.put(VACA_GUARDIAN_PHONE, this.vaca_guardian_phone);
		value.put(VACA_HOME_ADDRESS, this.vaca_home_address);
		value.put(VACA_CENSUS_ADDRESS, this.vaca_census_address);
		value.put(VACA_CENSUS_ADDRESS2, this.vaca_census_address2);
		value.put(VACA_IMMIGRATION_TIME, this.vaca_immigration_time);
		value.put(VACA_EMIGRATION_TIME, this.vaca_emigration_time);
		value.put(VACA_EMIGRATION_REASON, this.vaca_emigration_reason);
		value.put(VACA_VACCINE_ANOMALIES_HIS, this.vaca_vaccine_anomalies_his);
		value.put(VACA_CONTRAINDICATION, this.vaca_contraindication);
		value.put(VACA_INFECT_HIS, this.vaca_infect_his);
		value.put(VACA_CREATE_CARD_DATE, this.vaca_create_card_date);
		value.put(VACA_CREATE_CARD_PEOPLE, this.vaca_create_card_people);
		myContext.getContentResolver().update(CONTENT_URI_TB21, value, VACA_PROFILE_ID + " = " + pro + "", null);
		
	}
	public void selectVaccinationCard(int pro){
		Cursor cursor=myContext.getContentResolver().query(CONTENT_URI_TB21, null, 
				VACA_PROFILE_ID + "=" + pro + "", null, null);
		System.out.println("cursor.getCount="+cursor.getCount());
		while(cursor.moveToNext()){
		this.vaca_profile_id=cursor.getInt(cursor.getColumnIndex(VACA_PROFILE_ID));
		this.vaca_name= cursor.getString(cursor.getColumnIndex(VACA_NAME));
		this.vaca_sex= cursor.getString(cursor.getColumnIndex(VACA_SEX));
		this.vaca_born=cursor.getString(cursor.getColumnIndex(VACA_BORN));
		this.vaca_nation=cursor.getString(cursor.getColumnIndex(VACA_NATION));
		this.vaca_number_name= cursor.getString(cursor.getColumnIndex(VACA_NUMBER_NAME));
		this. vaca_child_id= cursor.getString(cursor.getColumnIndex(VACA_CHILD_ID));
		this. vaca_child_born_id=cursor.getString(cursor.getColumnIndex(VACA_CHILD_BORN_ID)); 
		this.vaca_guardian_name=cursor.getString(cursor.getColumnIndex(VACA_GUARDIAN_NAME));
		this.vaca_relation=cursor.getString(cursor.getColumnIndex(VACA_RELATION));
		this.vaca_guardian_phone=cursor.getString(cursor.getColumnIndex(VACA_GUARDIAN_PHONE)); 
		this.vaca_home_address=cursor.getString(cursor.getColumnIndex(VACA_HOME_ADDRESS)); 
		this.vaca_census_address=cursor.getInt(cursor.getColumnIndex(VACA_CENSUS_ADDRESS)); 
		this.vaca_census_address2=cursor.getString(cursor.getColumnIndex(VACA_CENSUS_ADDRESS2)); 
		this.vaca_immigration_time=cursor.getString(cursor.getColumnIndex(VACA_IMMIGRATION_TIME)); 
		this.vaca_emigration_time=cursor.getString(cursor.getColumnIndex(VACA_EMIGRATION_TIME)); 
		this.vaca_emigration_reason=cursor.getString(cursor.getColumnIndex(VACA_EMIGRATION_REASON)); 
		this.vaca_vaccine_anomalies_his=cursor.getString(cursor.getColumnIndex(VACA_VACCINE_ANOMALIES_HIS)); 
		this.vaca_contraindication=cursor.getString(cursor.getColumnIndex(VACA_CONTRAINDICATION)); 
		this.vaca_infect_his=cursor.getString(cursor.getColumnIndex(VACA_INFECT_HIS)); 
		this.vaca_create_card_date=cursor.getString(cursor.getColumnIndex(VACA_CREATE_CARD_DATE)); 
		this.vaca_create_card_people=cursor.getString(cursor.getColumnIndex(VACA_CREATE_CARD_PEOPLE));
		}
		cursor.close();
	}
/*	public void selectCode(int pro){
  		Cursor cursor = myContext.getContentResolver().query(CONTENT_URI_TB21, PROJECTION,
  				VACA_PROFILE_ID+ "=" + pro + "", null, null);
  		System.out.println("cursor.getCount="+cursor.getCount());
  		while(cursor.moveToNext()){
  			this.vaca_profile_id = cursor.getInt(cursor.getColumnIndex(VACA_PROFILE_ID));
  			this.vaca_name=cursor.getString(cursor.getColumnIndex(VACA_NAME));
  			break;
  		}
  		cursor.close();
  	}
	*/
	public void deleteVaccinationCard(int pro){
		myContext.getContentResolver().delete(CONTENT_URI_TB21, VACA_PROFILE_ID + "=" + pro + "", null);
	}
	
	
	

}
